exports.__esModule = true;
class CustFormService {
    //自定表单数据解析，
    getFormJsonValue(data) {
        let arr = [];
        for (let i in data) {
            let element = data[i];
            if (element.type == 'm-radio') {
                arr.push({ label: element.label, type: 'm-radio', value: element.value.name });
            } else if (element.type == 'm-datetime-range') {
                arr.push({
                    beginLabel: '开始时间',
                    type: 'm-datetime-range',
                    beginValue: element.value.begin,
                    endLabel: '结束时间',
                    endValue: element.value.end,
                    intervalLabel: '时长',
                    intervalValue: element.value.interval + element.value.intervalUnit
                });
            } else if (element.type == 'm-select-by-data') {
                arr.push({
                    depictLabel: '病症描述',
                    type: 'm-select-by-data',
                    depictValue: element.value.depict,
                    judgeDiseaseLabel: '预判病害',
                    judgeDiseaseValue: element.value.judge_disease,
                    pesticideLabel: '处置农药',
                    pesticideValue: element.value.pesticide
                });
            } else if (element.type == 'm-datetime') {
                arr.push({
                    label: element.label,
                    type: 'm-datetime',
                    value: element.value
                });
            } else if (element.type == 'm-textarea') {
                arr.push({ label: element.label, type: 'm-textarea', value: element.value.text });
            } else if (element.type == 'm-switch') {
                let value = '';
                if (element.value == 'false') {
                    value = '否';
                } else {
                    value = '是';
                }
                arr.push({ label: element.label, type: 'm-switch', value: value });
            } else if (element.type == 'm-scan') {
                arr.push({ label: element.label, type: 'm-scan', value: element.value });
            } else if (element.type == 'm-checkbox') {
                arr.push({ label: element.label, type: 'm-checkbox', value: element.value.name });
            } else if (element.type == 'm-upload-file') {
                if (element.value) {
                    arr.push({
                        label: element.label,
                        type: 'm-upload-file',
                        url: element.value.realpath,
                        value: element.value.fileName
                    });
                }
            } else if (element.type == 'm-upload-img') {
                let url = '';
                let fileName = '';
                element.value.map(item => {
                    url += item.url + ',';
                    fileName += item.fileName + ',';
                });
                arr.push({
                    label: element.label,
                    type: 'm-upload-img',
                    url: url.substr(0, url.length - 1),
                    value: fileName.substr(0, fileName.length - 1)
                });
            } else if (element.type == 'm-select-person') {
                arr.push({ label: element.label, type: 'm-select-person', value: element.value.realname });
            } else if (element.type == 'm-input') {
                arr.push({ label: element.label, type: 'm-input', value: element.value });
            } else if (element.type == 'm-gps-point') {
                arr.push({
                    label: element.label,
                    lon: element.lon,
                    lat: element.lat,
                    type: 'm-gps-point',
                    value: element.value.address
                });
            } else if (element.type == 'm-select-area') {
                arr.push({ label: element.label, value: element.value.name });
            }
        }
        return arr;
    }

}

exports.default = CustFormService;